//文件上传的内容放在这里

$(function(){
    $("#form-add").validate({
        rules:{
            name:{required:true},
            cid:{required:true},
            price:{required:true,number:true},
            stock:{required:true,digits:true},
            url:{required:true}

        },
        message: {
            name:{required: "必须填写该字段"},
            cid:{required: "必须选择分类"},
            stock:{digits: "必须输入整数"},
            price:{number: "必须输入数字"}
        }
    });

    $("#submit").on('click',function(){
        if($("#form-add").valid()){
            $.ajax({
                url:"/goods/save",
                type:"post",
                dataType:'json',
                data:$("#form-add").serialize(),
                success:function(data){

                    if(data ==1){
                        var index = layer.index;
                        location.replace(location.href);
                        layer.close(index);
                    }
                }
            });

        }
    });

});



